/*
 * Project: BoboDesignPattern
 * 
 * File Created at 2020年5月11日
 * 
 * Copyright 2012 Greenline.com Corporation Limited.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * Greenline Company. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Greenline.com.
 */
package test.practice;

import java.util.Stack;

/**
 * @Type ATemp
 * @Desc
 * @author 52489
 * @date 2020年5月11日
 * @Version V1.0
 */
public class ATemp {

    public class ListNode {
        int val;
        ListNode next;

        ListNode(int x) {
            val = x;
        }
    }

    public int[] reversePrint(ListNode head) {
        Stack<ListNode> stack = new Stack<>();
        do {
            stack.push(head);
            head = head.next;
        } while (null != head);
        System.out.println(stack.size());
        int num[] = new int[stack.size()];
        for (int i = 0; i < stack.size(); i++) {
            num[i] = stack.pop().val;
        }
        return num;
    }

    public static void main(String[] args) {
        ATemp temp = new ATemp();
        ATemp.ListNode head = temp.new ListNode(0);
        head.next = temp.new ListNode(1);
        head.next.next = temp.new ListNode(2);
        temp.reversePrint(head);
    }
}